﻿namespace NOAH.CMS.Cache
{
    using NOAH.CMS.Repository;
    using System;
    using System.Collections.Generic;
    using System.Linq;

    public class LinkCacheLayer : BaseCacheLayer
    {
        private LinkRepository _repositoryAPI = null;

        public List<Link> GetAll()
        {
            List<Link> cates = this.GetCacheItem("AllLink") as List<Link>;
            if (cates == null)
            {
                cates = (from p in this.API.GetAll()
                    orderby p.Order
                    select p).ToList<Link>();
                this.AddCacheItem("AllLink", cates);
            }
            return cates;
        }

        protected override string[] MasterCacheKeyArray()
        {
            return new string[] { "LinkCache" };
        }

        protected LinkRepository API
        {
            get
            {
                if (this._repositoryAPI == null)
                {
                    this._repositoryAPI = new LinkRepository();
                }
                return this._repositoryAPI;
            }
        }
    }
}

